ScrapboxのメニューにTweet Buttonを追加するUserScript
一行目だけをツイートするテスト
code:script.js
scrapbox.PageMenu.addMenu({
title: 'tweet',
onClick: () => {
const encodedUrl = encodeURIComponent(location.href);
const encodedTitle = encodeURIComponent(window.scrapbox.Page.title);
window.open(https://twitter.com/intent/tweet?url=${encodedUrl}&text=${encodedTitle})
}
});
/*
scrapbox.PageMenu('tweet').addItem({
title: 'Tweet with 1st line & link',
onClick: () => window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(window.scrapbox.Page.lines[1].text)})
});
scrapbox.PageMenu('tweet').addItem({
title: 'Tweet with title, 1st line & link',
onClick: () => window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(window.scrapbox.Page.title + '\r\n' + window.scrapbox.Page.lines[1].text)})
});
scrapbox.PageMenu('tweet').addItem({
title: 'Tweet only 1st line',
onClick: () => window.open(https://twitter.com/intent/tweet?text=${encodeURIComponent(window.scrapbox.Page.lines[1].text)})
});
*/